import _fetch from '@/Utils/Fetch';
import {
  mallManagement,
} from '@/Utils/Urls';

// 商家退款
export const refundThunk = (outTradeNo, reason) => () => new Promise((resolve, reject) => {
  const formdata = new FormData()
  formdata.append('outTradeNo', outTradeNo)
  formdata.append('reason', reason)
  _fetch({
    url: mallManagement.refund,
    type: 'post',
    data: formdata,
    headers: {
      "Content-Type": "multipart/form-data",
    }
  }).then(res => {
    if (res && res.status === 200) {
      resolve(res)
    } else {
      reject()
    }
  })
})

// 取消揽件
export const managerBorderOfficialCancelThunk = (cancelMsg, orderId) => () => new Promise((resolve, reject) => {
  const formdata = new FormData()
  formdata.append('cancelMsg', cancelMsg)
  formdata.append('orderId', orderId)
  _fetch({
    url: mallManagement.managerBorderOfficialCancel,
    type: 'post',
    data: formdata,
    headers: {
      "Content-Type": "multipart/form-data",
    }
  }).then(res => {
    if (res && res.status === 200) {
      resolve(res)
    } else {
      reject()
    }
  })
})